<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <f:metadata>
        <f:viewParam name="text" value="#{searchView.searchText}"> </f:viewParam>
        <f:viewParam name="page" value="#{searchView.backPage}"/>
        <f:viewAction action="#{searchView.init}"/>
    </f:metadata>


    <h:head>
        <title>Search Results</title>
    </h:head>


    <h:body>
       



        <h:form id="resultsForm">
            <p:inputText id="search" value="#{searchView.searchText}" required="true"/>
            <p:commandButton value="Submit" action="#{searchView.searchToInvite()}">
                <!-- <f:ajax render="resultsForm:userDetail" listener=""/>-->
            </p:commandButton>
            <p:dataList id="resList" var="user" value="#{searchView.results}" type="unordered" itemType="none" paginator="true" rows="10" styleClass="paginated">
                <f:facet name="header">
                    Results for #{searchView.searchText}:
                </f:facet>

                <p:panel>
                    <p:commandLink update=":resultsForm:userDetail" oncomplete="PF('userDialog').show()" title="user dettagli" styleClass="ui-icon ui-icon-search" style="float:right;margin-right:50px">
                        <f:setPropertyActionListener value = "#{user}" target="#{eventBean.selectedInvited}"/>
                        <h:outputText value="#{user.firstName}, #{user.lastName}" />
                    </p:commandLink>
                    <h:outputText value="#{user.firstName} #{user.lastName} (#{user.email}) [#{user.visibility} Calendar]" style="display:inline-block" />
                    <h:link value="#{user.email}" outcome="welcomePrimefaces" includeViewParams="true">
                        <f:param name="email" value="#{user.email}"></f:param>
                    </h:link>
                </p:panel>
            </p:dataList>
            
            
            

            <p:dialog header="User Info" widgetVar="userDialog" modal="true" showEffect="blind" hideEffect="explode" resizable="false">
                <p:outputPanel id="userDetail" style="text-align:center;">
                    <p:panelGrid columns="2" columnClasses="label,value">
                        <h:outputText value="First name:" />
                        <h:outputText value="#{eventBean.selectedInvited.firstName}" />

                        <h:outputText value="Last Name" />
                        <h:outputText value="#{eventBean.selectedInvited.lastName}" />

                        <h:outputText value="Calendar" />
                        <h:outputText value="#{eventBean.selectedInvited.visibility}" />
                        
                        <p:commandButton title="Invite" value="Invite" action="#{eventBean.invite()}"/>
                    </p:panelGrid>
                </p:outputPanel>
            </p:dialog>
        </h:form>
        <h:form>
            <p:commandButton id="back" value="Back" action="#{searchView.back()}"/>
        </h:form>
        <br/>

    </h:body>
</html>